<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/20 11:11
 */

namespace module\chat\front\table;

use module\chat\model\Category;
use mof\enum\StatusEnum;
use mof\front\Table;
use mof\utils\DictArray;
use mof\utils\ElementData;

class AssistantTable extends Table
{
    protected string $serverBaseUrl = '/{module}/admin/{table}';

    protected function columnId(): array
    {
        return [
            "prop"    => 'id',
            "label"   => 'ID',
            "visible" => false,
        ];
    }

    protected function columnCategoryId(): array
    {
        return [
            "prop"    => 'category_id',
            "label"   => '分类',
            "search"  => true,
            "type"    => "select",
            "options" => ElementData::make(Category::getListByType('assistant'))
                ->toSelectOptions('name', 'id')
        ];
    }

    protected function columnIcon(): array
    {
        return [
            "prop"  => 'icon',
            "label" => '图标',
            "width" => "80",
            "type"  => "avatar"
        ];
    }

    protected function columnName(): array
    {
        return [
            "prop"   => 'name',
            "label"  => '助手名称',
            "search" => true,
            "width"  => "*"
        ];
    }

    //简介intro
    protected function columnIntro(): array
    {
        return [
            "prop"  => 'intro',
            "label" => '简介',
            "width" => "*"
        ];
    }

    //收藏量
    protected function columnFavorCt(): array
    {
        return [
            "prop"  => 'favor_ct',
            "label" => '收藏量',
        ];
    }

    //使用量
    protected function columnUsedCt(): array
    {
        return [
            "prop"  => 'used_ct',
            "label" => '使用量',
        ];
    }

    //状态
    protected function columnStatus(): array
    {
        return [
            "prop"    => 'status',
            "label"   => '状态',
            "type"    => "select",
            "search"  => true,
            "options" => StatusEnum::toDict()->toElementData()->toSelectOptions(),
        ];
    }

    //新建时间
    protected function columnCreateAt(): array
    {
        return [
            "prop"  => 'create_at',
            "label" => '新建时间',
            "type"  => "datetime"
        ];
    }
}